home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cocktail
/
puma.lha
/
puma
/
src
/
Parser.lalr
< prev
next >
Wrap
Text File
|
1992-09-25
|
23KB
|
636 lines
PARSER Parser
GLOBAL {
FROM StringMem IMPORT GetString, PutString;
FROM Strings IMPORT tString, SubString, Length, ArrayToString, IntToString, Concatenate;
FROM Idents IMPORT tIdent, NoIdent, MakeIdent;
FROM Texts IMPORT tText, MakeText;
FROM Scanner IMPORT BeginScanner, tScanAttribute, Attribute, Warning;
FROM Positions IMPORT tPosition, NoPosition;
FROM Tree IMPORT
mSpec , mCodes , mAttrDesc , mDesignator ,
mLayoutAny , mNoLayout , mAnys ,
mNoDesignator, mIdent , mAny , mNamedExpr ,
mNoName , mName , mNoTreeName , mTreeName ,
mNoRoutine , mPredicate , mProcedure , mFunction ,
mType , mNoParameter , mParam , mNoRule ,
mRule , mNoExpr , mCompose , mVarUse ,
mTargetExpr , mDontCare1 , mDontCare , mOneExpr ,
mNoStatement , mTargetStmt , mAssignment , mCall ,
mBinary , mPreOperator , mPostOperator , mParents ,
mProcCall , mReject , mFail , mNl ,
mStringExpr , mNil , mIndex , Nil ,
mOnePatternsList, mNoPatternsList , OnePatternsList ,
tTree , Compose , VarUse , CopyTree ,
TreeRoot , MakeTree , Codes , ReverseTree ;
VAR
String1, String2 : tString;
NameCount : INTEGER;
Line : tPosition;
nNoParameter, nNoName, nNoRule, nNoDesignator,
nNoStatement, nNoLayout, nNoPatternsList: tTree;
PROCEDURE mRules (Line: tPosition; Patterns, Exprs, Expr, Statements, Next: tTree): tTree;
VAR Tree : tTree;
BEGIN
Tree := mRule (Line, Patterns^.OnePatternsList.Patterns, Exprs, Expr, Statements, Next);
Patterns := Patterns^.OnePatternsList.Next;
WHILE Patterns^.Kind = OnePatternsList DO
Tree := mRule (Line, Patterns^.OnePatternsList.Patterns, CopyTree (Exprs),
CopyTree (Expr), CopyTree (Statements), Tree);
Patterns := Patterns^.OnePatternsList.Next;
END;
RETURN Tree;
END mRules;
TYPE
yyTrafoName = RECORD Id: tIdent; END;
yyTreePart = RECORD Tree: tTree; END;
yyTreeNames = RECORD Tree: tTree; END;
yyPublicPart = RECORD Tree: tTree; END;
yyExternPart0 = RECORD Tree: tTree; END;
yyExternPart = RECORD Tree: tTree; END;
yyNames = RECORD Tree: tTree; END;
yyCodes = RECORD Tree: tTree; END;
yyRoutines = RECORD Tree: tTree; END;
yyOutParameters = RECORD Tree: tTree; END;
yyParameters = RECORD Tree: tTree; END;
yyMode = RECORD IsRef: BOOLEAN; END;
yyDeclarations = RECORD Tree: tTree; END;
yyType = RECORD Tree: tTree; END;
yyLocalCode = RECORD Text: tText; Position: tPosition; END;
yyRules = RECORD Tree: tTree; END;
yyPatterns = RECORD Tree: tTree; END;
yyPatterns2 = RECORD Tree: tTree; END;
yyExprs = RECORD Tree: tTree; END;
yyNamedExprs = RECORD Tree: tTree; END;
yyExprs2 = RECORD Tree: tTree; END;
yyNamedExprs2 = RECORD Tree: tTree; END;
yyExpr = RECORD Tree: tTree; END;
yyPrefixExpr = RECORD Tree: tTree; END;
yyPostfixExpr = RECORD Tree: tTree; END;
yyPrimaryExpr = RECORD Tree: tTree; END;
yyStatements = RECORD Tree: tTree; END;
yyTargetCodes = RECORD Tree: tTree; END;
yyName0 = RECORD Id: tIdent; Position: tPosition; END;
yyName1 = RECORD Id: tIdent; Position: tPosition; END;
yySpace = RECORD Tree: tTree; END;
tParsAttribute = RECORD CASE : SHORTCARD OF
0: Scan: Scanner.tScanAttribute;
| 1: TrafoName: yyTrafoName;
| 2: TreePart: yyTreePart;
| 3: TreeNames: yyTreeNames;
| 4: PublicPart: yyPublicPart;
| 5: ExternPart0: yyExternPart0;
| 6: ExternPart: yyExternPart;
| 7: Names: yyNames;
| 8: Codes: yyCodes;
| 9: Routines: yyRoutines;
| 10: OutParameters: yyOutParameters;
| 11: Parameters: yyParameters;
| 12: Mode: yyMode;
| 13: Declarations: yyDeclarations;
| 14: Type: yyType;
| 15: LocalCode: yyLocalCode;
| 16: Rules: yyRules;
| 17: Patterns: yyPatterns;
| 18: Patterns2: yyPatterns2;
| 19: Exprs: yyExprs;
| 20: NamedExprs: yyNamedExprs;
| 21: Exprs2: yyExprs2;
| 22: NamedExprs2: yyNamedExprs2;
| 23: Expr: yyExpr;
| 24: PrefixExpr: yyPrefixExpr;
| 25: PostfixExpr: yyPostfixExpr;
| 26: PrimaryExpr: yyPrimaryExpr;
| 27: Statements: yyStatements;
| 28: TargetCodes: yyTargetCodes;
| 29: Name0: yyName0;
| 30: Name1: yyName1;
| 31: Space: yySpace;
END; END;
}
EXPORT {
}
LOCAL {
}
BEGIN {
BeginScanner;
NameCount := 0;
nNoParameter := mNoParameter ();
nNoName := mNoName ();
nNoRule := mNoRule ();
nNoDesignator := mNoDesignator ();
nNoStatement := mNoStatement ();
nNoLayout := mNoLayout ();
nNoPatternsList := mNoPatternsList ();
}
CLOSE {
}
TOKEN
Ident = 1
Operator = 2
IncOperator = 3
TargetBlock = 4
String = 5
Number = 6
TargetCode = 7
WhiteSpace = 8
'::' = 9
TRAFO = 10
'TREE' = 11
',' = 12
PUBLIC = 13
EXTERN = 14
';' = 15
'EXPORT' = 16
'IMPORT' = 17
'GLOBAL' = 18
'BEGIN' = 19
'CLOSE' = 20
PROCEDURE = 21
'(' = 22
REF = 23
':' = 24
'.' = 25
'[' = 26
']' = 27
'=>' = 28
')' = 29
'LOCAL' = 30
'..' = 31
NIL = 32
'_' = 33
'{' = 34
'}' = 35
'->' = 36
'^' = 37
':>' = 38
':=' = 39
'?' = 40
REJECT = 41
FAIL = 42
NL = 43
RETURN = 44
'FUNCTION' = 45
PREDICATE = 46
OPER
NONE '{'
NONE HIGH
RULE
Trafo : TrafoName TreePart PublicPart ExternPart0 Codes Routines { ;
TreeRoot := mSpec ($1.TrafoName.Id, $2.TreePart.Tree, $3.PublicPart.Tree,
$4.ExternPart0.Tree, $5.Codes.Tree, ReverseTree ($6.Routines.Tree)); ;
;
} .
TrafoName : { ArrayToString ("Trafo", String1); $$.TrafoName.Id := MakeIdent (String1); ;
;
} .
TrafoName : TRAFO Name0 {$$.TrafoName.Id := $2.Name0.Id;
} .
TreePart : { ArrayToString ("Tree", String1);
$$.TreePart.Tree := mTreeName (MakeIdent (String1), Attribute.Position, mNoTreeName ()); ;
;
} .
TreePart : 'TREE' TreeNames { $$.TreePart.Tree := ReverseTree ($2.TreeNames.Tree);
;
} .
TreeNames : { $$.TreeNames.Tree := mNoTreeName ();
;
} .
TreeNames : TreeNames ',' {$$.TreeNames.Tree := $1.TreeNames.Tree;
} .
TreeNames : TreeNames Name0 { $$.TreeNames.Tree := mTreeName ($2.Name0.Id, $2.Name0.Position, $1.TreeNames.Tree);
;
} .
PublicPart : { $$.PublicPart.Tree := nNoName;
;
} .
PublicPart : PUBLIC Names { $$.PublicPart.Tree := ReverseTree ($2.Names.Tree);
;
} .
ExternPart0 : { $$.ExternPart0.Tree := nNoName;
;
} .
ExternPart0 : EXTERN Names OptSemiColon { $$.ExternPart0.Tree := ReverseTree ($2.Names.Tree);
;
} .
ExternPart : { $$.ExternPart.Tree := nNoName;
;
} .
ExternPart : EXTERN Names ';' { $$.ExternPart.Tree := ReverseTree ($2.Names.Tree);
;
} .
Names : { $$.Names.Tree := nNoName;
;
} .
Names : Names ',' {$$.Names.Tree := $1.Names.Tree;
} .
Names : Names Name0 { $$.Names.Tree := mName ($2.Name0.Id, $2.Name0.Position, $1.Names.Tree);
;
} .
Codes : { $$.Codes.Tree := MakeTree (Codes);
;
} .
Codes : Codes 'EXPORT' TargetBlock { $$.Codes.Tree := $1.Codes.Tree;
$$.Codes.Tree^.Codes.Export := $3.Scan.TargetBlock.Text;
$$.Codes.Tree^.Codes.ExportLine := $3.Scan.Position; ;
;
} .
Codes : Codes 'IMPORT' TargetBlock { $$.Codes.Tree := $1.Codes.Tree;
$$.Codes.Tree^.Codes.Import := $3.Scan.TargetBlock.Text;
$$.Codes.Tree^.Codes.ImportLine := $3.Scan.Position; ;
;
} .
Codes : Codes 'GLOBAL' TargetBlock { $$.Codes.Tree := $1.Codes.Tree;
$$.Codes.Tree^.Codes.Global := $3.Scan.TargetBlock.Text;
$$.Codes.Tree^.Codes.GlobalLine := $3.Scan.Position; ;
;
} .
Codes : Codes 'BEGIN' TargetBlock { $$.Codes.Tree := $1.Codes.Tree;
$$.Codes.Tree^.Codes.Begin := $3.Scan.TargetBlock.Text;
$$.Codes.Tree^.Codes.BeginLine := $3.Scan.Position; ;
;
} .
Codes : Codes 'CLOSE' TargetBlock { $$.Codes.Tree := $1.Codes.Tree;
$$.Codes.Tree^.Codes.Close := $3.Scan.TargetBlock.Text;
$$.Codes.Tree^.Codes.CloseLine := $3.Scan.Position; ;
;
} .
Routines : { $$.Routines.Tree := mNoRoutine ();
;
} .
Routines : Routines PROCEDURE Name0 '(' Parameters OutParameters ')' ExternPart LocalCode Rules { $$.Routines.Tree := mProcedure ($1.Routines.Tree, $3.Name0.Id, $3.Name0.Position,
$5.Parameters.Tree, $6.OutParameters.Tree, $8.ExternPart.Tree, $9.LocalCode.Text,
$9.LocalCode.Position, ReverseTree ($10.Rules.Tree));
;
} .
Routines : Routines 'FUNCTION' Name0 '(' Parameters OutParameters ')' Type ExternPart LocalCode Rules { $$.Routines.Tree := mFunction ($1.Routines.Tree, $3.Name0.Id, $3.Name0.Position,
$5.Parameters.Tree, $6.OutParameters.Tree, $9.ExternPart.Tree, $10.LocalCode.Text,
$10.LocalCode.Position, ReverseTree ($11.Rules.Tree),
mParam (FALSE, NoIdent, NoPosition, $8.Type.Tree, nNoParameter));
;
} .
Routines : Routines PREDICATE Name0 '(' Parameters OutParameters ')' ExternPart LocalCode Rules { $$.Routines.Tree := mPredicate ($1.Routines.Tree, $3.Name0.Id, $3.Name0.Position,
$5.Parameters.Tree, $6.OutParameters.Tree, $8.ExternPart.Tree, $9.LocalCode.Text,
$9.LocalCode.Position, ReverseTree ($10.Rules.Tree));
;
} .
OutParameters : { $$.OutParameters.Tree := nNoParameter;
;
} .
OutParameters : '=>' Parameters {$$.OutParameters.Tree := $2.Parameters.Tree;
} .
Parameters : { $$.Parameters.Tree := nNoParameter;
;
} PREC HIGH .
Parameters : Mode Ident ':' Type { $$.Parameters.Tree := mParam ($1.Mode.IsRef, $2.Scan.Ident.Ident, $2.Scan.Position, $4.Type.Tree, nNoParameter);
;
} .
Parameters : Mode Type { ArrayToString ("yyP", String1); INC (NameCount);
IntToString (NameCount, String2); Concatenate (String1, String2);
$$.Parameters.Tree := mParam ($1.Mode.IsRef, MakeIdent (String1), NoPosition, $2.Type.Tree, nNoParameter); ;
;
} .
Parameters : Mode Ident ':' Type ',' Parameters { $$.Parameters.Tree := mParam ($1.Mode.IsRef, $2.Scan.Ident.Ident, $2.Scan.Position, $4.Type.Tree, $6.Parameters.Tree);
;
} .
Parameters : Mode Type ',' Parameters { ArrayToString ("yyP", String1); INC (NameCount);
IntToString (NameCount, String2); Concatenate (String1, String2);
$$.Parameters.Tree := mParam ($1.Mode.IsRef, MakeIdent (String1), NoPosition, $2.Type.Tree, $4.Parameters.Tree); ;
;
} .
Mode : { $$.Mode.IsRef := FALSE;
;
} .
Mode : REF { $$.Mode.IsRef := TRUE ;
;
} .
Declarations : Ident ':' Type { $$.Declarations.Tree := mParam (FALSE, $1.Scan.Ident.Ident, $1.Scan.Position, $3.Type.Tree, nNoParameter);
;
} .
Declarations : Ident ':' Type ',' Declarations { $$.Declarations.Tree := mParam (FALSE, $1.Scan.Ident.Ident, $1.Scan.Position, $3.Type.Tree, $5.Declarations.Tree);
;
} .
Type : Ident { $$.Type.Tree := mType ($1.Scan.Ident.Ident, $1.Scan.Position, nNoName);
;
} .
Type : Ident '.' Name0 { $$.Type.Tree := mType ($1.Scan.Ident.Ident, $1.Scan.Position, mName ($3.Name0.Id, $3.Name0.Position, nNoName));
;
} .
Type : '[' Names ']' { $$.Type.Tree := mType (NoIdent, $1.Scan.Position, ReverseTree ($2.Names.Tree));
;
} .
Type : Ident '.' '[' Names ']' { $$.Type.Tree := mType ($1.Scan.Ident.Ident, $1.Scan.Position, ReverseTree ($4.Names.Tree));
;
} .
LocalCode : { MakeText ($$.LocalCode.Text); ;
$$.LocalCode.Position := NoPosition;
;
} .
LocalCode : 'LOCAL' TargetBlock {$$.LocalCode.Position := $2.Scan.Position;
$$.LocalCode.Text := $2.Scan.TargetBlock.Text;
} .
Rules : { $$.Rules.Tree := nNoRule;
;
} .
Rules : Rules SetLine Patterns2 '.' { $$.Rules.Tree := mRules (Line, $3.Patterns2.Tree, mNoExpr ($4.Scan.Position),
mNoExpr ($4.Scan.Position), nNoStatement, $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '?' Statements '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, mNoExpr ($6.Scan.Position),
mNoExpr ($6.Scan.Position), ReverseTree ($5.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '=>' Exprs2 '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $5.Exprs2.Tree, mNoExpr ($6.Scan.Position),
nNoStatement, $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns RETURN Expr ';' '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, mNoExpr ($7.Scan.Position), $5.Expr.Tree,
nNoStatement, $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '=>' Exprs '?' Statements '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $5.Exprs.Tree, mNoExpr ($8.Scan.Position),
ReverseTree ($7.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '?' Statements '=>' Exprs2 '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $7.Exprs2.Tree, mNoExpr ($8.Scan.Position),
ReverseTree ($5.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '=>' Exprs RETURN Expr ';' '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $5.Exprs.Tree, $7.Expr.Tree,
nNoStatement, $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns RETURN Expr OptSemiColon '?' Statements '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, mNoExpr ($9.Scan.Position), $5.Expr.Tree,
ReverseTree ($8.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '?' Statements RETURN Expr ';' '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, mNoExpr ($9.Scan.Position), $7.Expr.Tree,
ReverseTree ($5.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '=>' Exprs RETURN Expr OptSemiColon '?' Statements '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $5.Exprs.Tree, $7.Expr.Tree,
ReverseTree ($10.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '=>' Exprs '?' Statements RETURN Expr ';' '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $5.Exprs.Tree, $9.Expr.Tree,
ReverseTree ($7.Statements.Tree), $1.Rules.Tree);
;
} .
Rules : Rules SetLine Patterns '?' Statements '=>' Exprs RETURN Expr ';' '.' { $$.Rules.Tree := mRules (Line, $3.Patterns.Tree, $7.Exprs.Tree, $9.Expr.Tree,
ReverseTree ($5.Statements.Tree), $1.Rules.Tree);
;
} .
SetLine : { ;
Line := Attribute.Position; ;
;
} .
OptSemiColon : .
OptSemiColon : ';' .
Patterns : Exprs { $$.Patterns.Tree := mOnePatternsList ($1.Exprs.Tree, nNoPatternsList);
;
} .
Patterns : Exprs ';' Patterns { $$.Patterns.Tree := mOnePatternsList ($1.Exprs.Tree, $3.Patterns.Tree);
;
} .
Patterns2 : Exprs ';' { $$.Patterns2.Tree := mOnePatternsList ($1.Exprs.Tree, nNoPatternsList);
;
} .
Patterns2 : Exprs ';' Patterns2 { $$.Patterns2.Tree := mOnePatternsList ($1.Exprs.Tree, $3.Patterns2.Tree);
;
} .
Exprs : '..' { $$.Exprs.Tree := mOneExpr (mDontCare ($1.Scan.Position), mNoExpr (Attribute.Position));
;
} .
Exprs : '..' ',' { $$.Exprs.Tree := mOneExpr (mDontCare ($1.Scan.Position), mNoExpr (Attribute.Position));
;
} .
Exprs : Expr { $$.Exprs.Tree := mOneExpr ($1.Expr.Tree, mNoExpr (Attribute.Position));
;
} .
Exprs : Expr ',' Exprs { $$.Exprs.Tree := mOneExpr ($1.Expr.Tree, $3.Exprs.Tree);
;
} .
Exprs : NamedExprs {$$.Exprs.Tree := $1.NamedExprs.Tree;
} .
NamedExprs : { $$.NamedExprs.Tree := mNoExpr (Attribute.Position);
;
} .
NamedExprs : Ident ':=' Expr { $$.NamedExprs.Tree := mNamedExpr ($3.Expr.Tree, mNoExpr (Attribute.Position), $1.Scan.Ident.Ident);
;
} .
NamedExprs : Ident ':=' Expr ',' NamedExprs { $$.NamedExprs.Tree := mNamedExpr ($3.Expr.Tree, $5.NamedExprs.Tree, $1.Scan.Ident.Ident);
;
} .
Exprs2 : '..' { $$.Exprs2.Tree := mOneExpr (mDontCare ($1.Scan.Position), mNoExpr (Attribute.Position));
;
} .
Exprs2 : '..' ',' { $$.Exprs2.Tree := mOneExpr (mDontCare ($1.Scan.Position), mNoExpr (Attribute.Position));
;
} .
Exprs2 : Expr ',' Exprs2 { $$.Exprs2.Tree := mOneExpr ($1.Expr.Tree, $3.Exprs2.Tree);
;
} .
Exprs2 : NamedExprs2 {$$.Exprs2.Tree := $1.NamedExprs2.Tree;
} .
NamedExprs2 : { $$.NamedExprs2.Tree := mNoExpr (Attribute.Position);
;
} .
NamedExprs2 : Ident ':=' Expr ',' NamedExprs2 { $$.NamedExprs2.Tree := mNamedExpr ($3.Expr.Tree, $5.NamedExprs2.Tree, $1.Scan.Ident.Ident);
;
} .
Expr : PrefixExpr {$$.Expr.Tree := $1.PrefixExpr.Tree;
} .
Expr : Expr Operator PrefixExpr { $$.Expr.Tree := mBinary ($2.Scan.Position, $1.Expr.Tree, $2.Scan.Operator.Ident, $3.PrefixExpr.Tree);
;
} .
PrefixExpr : PostfixExpr {$$.PrefixExpr.Tree := $1.PostfixExpr.Tree;
} .
PrefixExpr : Ident ':' PostfixExpr {
$$.PrefixExpr.Tree := $3.PostfixExpr.Tree;
IF $$.PrefixExpr.Tree^.Kind = Compose THEN
$$.PrefixExpr.Tree^.Compose.Selector := $1.Scan.Ident.Ident;
ELSIF $$.PrefixExpr.Tree^.Kind = Nil THEN
$$.PrefixExpr.Tree^.Nil.Selector := $1.Scan.Ident.Ident;
ELSIF $$.PrefixExpr.Tree^.Kind = VarUse THEN
$$.PrefixExpr.Tree := mCompose ($$.PrefixExpr.Tree^.VarUse.Pos, $1.Scan.Ident.Ident, $$.PrefixExpr.Tree,
mOneExpr (mDontCare ($$.PrefixExpr.Tree^.VarUse.Pos),
mNoExpr ($$.PrefixExpr.Tree^.VarUse.Pos)), FALSE);
ELSE
Warning ("label ignored", $1.Scan.Position);
END; ;
;
} .
PrefixExpr : Ident ':>' PostfixExpr {
$$.PrefixExpr.Tree := $3.PostfixExpr.Tree;
IF $$.PrefixExpr.Tree^.Kind = Compose THEN
$$.PrefixExpr.Tree^.Compose.Selector := $1.Scan.Ident.Ident;
$$.PrefixExpr.Tree^.Compose.Widen := TRUE;
ELSIF $$.PrefixExpr.Tree^.Kind = Nil THEN
$$.PrefixExpr.Tree^.Nil.Selector := $1.Scan.Ident.Ident;
ELSIF $$.PrefixExpr.Tree^.Kind = VarUse THEN
$$.PrefixExpr.Tree := mCompose ($$.PrefixExpr.Tree^.VarUse.Pos, $1.Scan.Ident.Ident, $$.PrefixExpr.Tree,
mOneExpr (mDontCare ($$.PrefixExpr.Tree^.VarUse.Pos),
mNoExpr ($$.PrefixExpr.Tree^.VarUse.Pos)), TRUE);
ELSE
Warning ("label ignored", $1.Scan.Position);
END; ;
;
} .
PrefixExpr : Operator PrefixExpr { $$.PrefixExpr.Tree := mPreOperator ($1.Scan.Position, $1.Scan.Operator.Ident, $2.PrefixExpr.Tree);
;
} .
PrefixExpr : IncOperator PrefixExpr { $$.PrefixExpr.Tree := mPreOperator ($1.Scan.Position, $1.Scan.IncOperator.Ident, $2.PrefixExpr.Tree);
;
} .
PostfixExpr : PrimaryExpr {$$.PostfixExpr.Tree := $1.PrimaryExpr.Tree;
} .
PostfixExpr : PostfixExpr '[' Exprs ']' { $$.PostfixExpr.Tree := mIndex ($2.Scan.Position, $1.PostfixExpr.Tree, $3.Exprs.Tree);
;
} .
PostfixExpr : PostfixExpr '(' Exprs ')' { $$.PostfixExpr.Tree := mCompose ($2.Scan.Position, NoIdent, $1.PostfixExpr.Tree, $3.Exprs.Tree, FALSE);
;
} .
PostfixExpr : PostfixExpr '(' Exprs '=>' Exprs ')' { $$.PostfixExpr.Tree := mCall ($2.Scan.Position, $1.PostfixExpr.Tree, $3.Exprs.Tree, $5.Exprs.Tree);
;
} .
PostfixExpr : PostfixExpr '.' Ident { ArrayToString (".", String1);
$$.PostfixExpr.Tree := mBinary ($2.Scan.Position, $1.PostfixExpr.Tree, MakeIdent (String1),
mVarUse ($3.Scan.Position, $3.Scan.Ident.Ident)); ;
;
} .
PostfixExpr : PostfixExpr '->' Ident { ArrayToString ("->", String1);
$$.PostfixExpr.Tree := mBinary ($2.Scan.Position, $1.PostfixExpr.Tree, MakeIdent (String1),
mVarUse ($3.Scan.Position, $3.Scan.Ident.Ident)); ;
;
} .
PostfixExpr : PostfixExpr '^' { ArrayToString ("^", String1);
$$.PostfixExpr.Tree := mPostOperator ($2.Scan.Position, MakeIdent (String1), $1.PostfixExpr.Tree); ;
;
} .
PostfixExpr : PostfixExpr IncOperator { $$.PostfixExpr.Tree := mPostOperator ($2.Scan.Position, $2.Scan.IncOperator.Ident, $1.PostfixExpr.Tree);
;
} .
PrimaryExpr : Ident { $$.PrimaryExpr.Tree := mVarUse ($1.Scan.Position, $1.Scan.Ident.Ident);
;
} .
PrimaryExpr : NIL { $$.PrimaryExpr.Tree := mNil ($1.Scan.Position, NoIdent);
;
} .
PrimaryExpr : '_' { $$.PrimaryExpr.Tree := mDontCare1 ($1.Scan.Position);
;
} .
PrimaryExpr : Number { $$.PrimaryExpr.Tree := mTargetExpr ($1.Scan.Position, mAny ($1.Scan.Number.StringRef, nNoDesignator));
;
} .
PrimaryExpr : String { $$.PrimaryExpr.Tree := mStringExpr ($1.Scan.Position, $1.Scan.String.StringRef);
;
} .
PrimaryExpr : Ident '::' Ident { $$.PrimaryExpr.Tree := mAttrDesc ($3.Scan.Position, $1.Scan.Ident.Ident, $3.Scan.Ident.Ident);
;
} .
PrimaryExpr : '{' TargetCodes '}' { $$.PrimaryExpr.Tree := mTargetExpr ($1.Scan.Position, ReverseTree ($2.TargetCodes.Tree));
;
} PREC '{' .
PrimaryExpr : '(' Expr ')' { $$.PrimaryExpr.Tree := mParents ($1.Scan.Position, $2.Expr.Tree);
;
} .
Statements : { $$.Statements.Tree := nNoStatement;
;
} .
Statements : Statements Expr ';' { $$.Statements.Tree := mProcCall ($2.Expr.Tree^.Expr.Pos, $1.Statements.Tree, $2.Expr.Tree);
;
} .
Statements : Statements Expr ':=' Expr ';' { $$.Statements.Tree := mAssignment ($3.Scan.Position, $1.Statements.Tree, $2.Expr.Tree, $4.Expr.Tree);
;
} .
Statements : Statements REJECT { $$.Statements.Tree := mReject ($2.Scan.Position, $1.Statements.Tree);
;
} .
Statements : Statements FAIL { $$.Statements.Tree := mFail ($2.Scan.Position, $1.Statements.Tree);
;
} .
Statements : Statements Declarations ';' { $$.Statements.Tree := mTargetStmt ($3.Scan.Position, $1.Statements.Tree, $2.Declarations.Tree, nNoDesignator);
;
} .
Statements : Statements '{' TargetCodes '}' ';' { $$.Statements.Tree := mTargetStmt ($2.Scan.Position, $1.Statements.Tree, nNoParameter, ReverseTree ($3.TargetCodes.Tree));
;
} .
Statements : Statements NL { $$.Statements.Tree := mNl ($2.Scan.Position, $1.Statements.Tree);
;
} .
Statements : Statements ';' {$$.Statements.Tree := $1.Statements.Tree;
} .
TargetCodes : { $$.TargetCodes.Tree := nNoDesignator;
;
} .
TargetCodes : TargetCodes Name1 Space '::' Space Ident { $$.TargetCodes.Tree := mDesignator ($2.Name1.Id, $6.Scan.Ident.Ident, $2.Name1.Position, $1.TargetCodes.Tree);
;
} .
TargetCodes : TargetCodes Name1 Space '::' Space {
$$.TargetCodes.Tree := mIdent ($2.Name1.Id, $2.Name1.Position, $1.TargetCodes.Tree);
$$.TargetCodes.Tree := mAnys (ReverseTree ($3.Space.Tree), $$.TargetCodes.Tree);
$$.TargetCodes.Tree := mAny ($4.Scan.yy9.StringRef, $$.TargetCodes.Tree);
$$.TargetCodes.Tree := mAnys (ReverseTree ($5.Space.Tree), $$.TargetCodes.Tree); ;
;
} .
TargetCodes : TargetCodes Name1 Space {
$$.TargetCodes.Tree := mIdent ($2.Name1.Id, $2.Name1.Position, $1.TargetCodes.Tree);
$$.TargetCodes.Tree := mAnys (ReverseTree ($3.Space.Tree), $$.TargetCodes.Tree); ;
;
} .
TargetCodes : TargetCodes '::' { $$.TargetCodes.Tree := mAny ($2.Scan.yy9.StringRef, $1.TargetCodes.Tree);
;
} .
TargetCodes : TargetCodes TargetCode { $$.TargetCodes.Tree := mAny ($2.Scan.TargetCode.StringRef, $1.TargetCodes.Tree);
;
} .
TargetCodes : TargetCodes WhiteSpace { $$.TargetCodes.Tree := mAny ($2.Scan.WhiteSpace.StringRef, $1.TargetCodes.Tree);
;
} .
Name0 : Ident { $$.Name0.Id := $1.Scan.Ident.Ident;
$$.Name0.Position := $1.Scan.Position;
;
} .
Name0 : String { GetString ($1.Scan.String.StringRef, String1);
SubString (String1, 2, Length (String1) - 1, String2);
$$.Name0.Id := MakeIdent (String2); ;
$$.Name0.Position := $1.Scan.Position;
;
} .
Name1 : Ident { $$.Name1.Id := $1.Scan.Ident.Ident;
$$.Name1.Position := $1.Scan.Position;
;
} .
Name1 : String { GetString ($1.Scan.String.StringRef, String1); $$.Name1.Id := MakeIdent (String1); ;
$$.Name1.Position := $1.Scan.Position;
;
} .
Space : { $$.Space.Tree := nNoLayout;
;
} .
Space : Space WhiteSpace { $$.Space.Tree := mLayoutAny ($2.Scan.WhiteSpace.StringRef, $1.Space.Tree);
;
} .